//
//  ReleaseDealViewController.m
//  shuiyun
//
//  Created by 徐双 on 2017/9/6.
//  Copyright © 2017年 qianyi. All rights reserved.
//

#import "ReleaseDealViewController.h"
#import "ReleaseRecodeViewCell.h"
#import "ReleaseTextViewTableViewCell.h"
#import "ReleaseChangeViewCell.h"
#import "BoatStyleViewController.h"

@interface ReleaseDealViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;

@end

@implementation ReleaseDealViewController

- (void)viewWillAppear:(BOOL)animated{
    
    
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:NO];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self creationView];
    [self regeditCell];
    
    // Do any additional setup after loading the view.
}
- (void)creationView {
    [super viewDidLoad];
    
    [self setTitle:@"发布船舶"];
    
    
    
    //初始化tableView
    
    self.tableView = [[UITableView alloc] init];
    self.tableView.frame = CGRectMake(0, 0, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT - 64);
    
    
    self.tableView.tableFooterView = [[UITableView alloc] initWithFrame:CGRectZero];
    
    self.tableView.backgroundColor = [UIColor whiteColor];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    // self.tableView.estimatedRowHeight = 400;
    self.tableView.separatorStyle = UITableViewCellAccessoryNone;//去掉分割线
    
    
    [self.view addSubview:self.tableView];
    self.view.backgroundColor = [UIColor colorWithRed:245 / 255.0f green:245 / 255.0f blue:245 / 255.0f alpha:1];
    
    UIButton *buttonOut = [[UIButton alloc] init];
    [self.view addSubview:buttonOut];
    [buttonOut mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view).offset(16);
        make.right.equalTo(self.view).offset(-16);
        make.bottom.equalTo(self.view).offset(-9);
        make.height.offset(40);
        
    }];
    [buttonOut setTitle:@"发布" forState:UIControlStateNormal];
    buttonOut.backgroundColor = getColor(@"3F87F6");
    [buttonOut setTitleColor:getColor(@"FFFFFF") forState:UIControlStateNormal];
    [buttonOut addTarget:self action:@selector(publicLick) forControlEvents:UIControlEventTouchUpInside];
    
}

-(void)publicLick{
    
}


-(void)regeditCell{
    
    [self.tableView registerNib:[UINib nibWithNibName:@"ReleaseRecodeViewCell" bundle:nil] forCellReuseIdentifier:@"ReleaseRecodeViewCell"];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"ReleaseTextViewTableViewCell" bundle:nil] forCellReuseIdentifier:@"ReleaseTextViewTableViewCell"];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"ReleaseChangeViewCell" bundle:nil] forCellReuseIdentifier:@"ReleaseChangeViewCell"];
    
}

#pragma mark - ---------- Cell的数量 ----------
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 14;
    
    
}

#pragma mark - ---------- 每个Cell的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 13) {
        
        return 200;
    }
    
    return 50;
    
}

#pragma mark - ---------- 每个Cell的内容 ----------
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
  
    ReleaseRecodeViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"ReleaseRecodeViewCell"];
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    if (indexPath.row == 0) {
        
        cell.nameLabel.text = @"信息主题:";
        cell.textView.placeholder = @"请输入货源名称";
        
    }else if (indexPath.row == 1){
        
        cell.nameLabel.text = @"交易类别:";
        cell.textView.placeholder = @"请输入重量";
    }else if (indexPath.row == 2){
        
        ReleaseChangeViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"ReleaseChangeViewCell"];
          cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.nameLabel2.text = @"船舶类型:";
        cell.TextView2.placeholder = @"请输入船舶种类";
        return cell;
    }else if (indexPath.row == 3){
        
        cell.nameLabel.text = @"有效期:";
        cell.textView.placeholder = @"请输入起运港";
    }else if (indexPath.row == 4){
        
        cell.nameLabel.text = @"报价:";
        cell.textView.placeholder = @"请输入到达港(不填写视为面议)";
    }else if (indexPath.row == 5){
        
        cell.nameLabel.text = @"建造时间:";
        cell.textView.placeholder = @"请输入建造时间";
    }else if (indexPath.row == 6){
        
        cell.nameLabel.text = @"建造地点:";
        cell.textView.placeholder = @"请输入建造地点";
    }else if (indexPath.row == 7){
        
        cell.nameLabel.text = @"实载量:";
        cell.textView.placeholder = @"请输入载重量";
    }else if (indexPath.row == 8){
        
        cell.nameLabel.text = @"船长(米):";
        cell.textView.placeholder = @"请输入船长";
    }else if (indexPath.row == 9){
        
        cell.nameLabel.text = @"船深(米):";
        cell.textView.placeholder = @"请输入船深";
    }else if (indexPath.row == 10){
        
        cell.nameLabel.text = @"联系人:";
        cell.textView.placeholder = @"请输入姓名";
    }else if (indexPath.row == 11){
        
        cell.nameLabel.text = @"联系电话:";
        cell.textView.placeholder = @"请输入手机号";
    }else if (indexPath.row == 12){
        
        cell.nameLabel.text = @"建造地点:";
        cell.textView.placeholder = @"请输入建造地点";
    }else{
        
        ReleaseTextViewTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"ReleaseTextViewTableViewCell"];
          cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        cell.contentLabel.text = @"船舶备注:";
        
        return cell;
        
    }
    
    return cell;
    
}
#pragma mark - ---------- 每个Cell的点击事件 ----------
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (indexPath.row == 2) {
        
        BoatStyleViewController * vc = [[BoatStyleViewController alloc] init];
        
        vc.hidesBottomBarWhenPushed = YES;
        
        [self.navigationController pushViewController:vc animated:YES];
        
        
    }
    
}
@end
